import { RJSFSchema, UiSchema } from '@rjsf/utils';
import { SourceType, TabsType } from './type';
import i18n from '@/common/utils/i18next';
import { CollapseTemplate } from 'nextcae-base/src/ui';
import { SelectionPickField } from '@/components/FieldTemplate/SelectionPickField';
import { DirectionField, DirectionType } from '@/components/DirectionField';
import { AssignDirection } from './AssignDirection';
import { GuideLine } from './GuideLine';
export const schema: RJSFSchema = {
  type: 'object',
  properties: {
    Tabs: {
      type: 'string',
      items: { type: 'string' },
      default: TabsType.AssignDirection,
    },
    Selection: {
      type: 'object',
      title: '选择',
      properties: {
        source: {
          title: i18n.t('Source'),
          type: 'array',

          ...{
            'x-options': [
              {
                const: SourceType.ShellElement,
                title: '面网格',
              },
              // {
              //   const: SourceType.ShellElement,
              //   title: '表面网格',
              // },
            ],
          },
        },
      },
    },
    Options: {},
    AddTo: {
      type: 'object',
      title: i18n.t('添加到'),
      properties: {
        property: {
          title: i18n.t('属性'),
          type: 'number',
          ...{
            JsonPath: 'FE Structure.PROPERTY',
            hasAdd: true,
            args: { type: 'property', c: 'property.new' },
            params: { pType: 'shell', color: 0x856805, type: 0 },
          },
        },
        part: {
          title: i18n.t('部件'),
          type: 'number',
          ...{
            JsonPath: 'Part.PART',
            hasAdd: true,
            args: { c: 'part.new' },
            params: { type: 'part' },
          },
        },
      },
    },
  },
  allOf: [AssignDirection, GuideLine],
};
export const uiSchema: UiSchema = {
  Tabs: {
    'ui:field': 'tabsField',
    'ui:options': {
      options: [
        {
          const: TabsType.AssignDirection,
          title: i18n.t('Assign Direction'),
          icon: 'commands/mesh/assign-direction',
        },
        {
          const: TabsType.GuideLine,
          title: i18n.t('Guide Line'),
          icon: 'commands/mesh/guide-line',
        },
      ],
    },
  },
  Selection: {
    'ui:FieldTemplate': CollapseTemplate,
    'ui:layout': [1, 2],
    'ui:options': {
      label: false, // 不显示 label
    },
    source: {
      'ui:field': SelectionPickField,
      'ui:focused': true,
    },
    guide: {
      'ui:field': SelectionPickField,
    },
    guideType: {
      'ui:widget': 'hidden',
      'ui:options': {
        label: '',
      },
    },
    reverse: {
      'ui:widget': 'checkbox',
    },
  },
  Options: {
    'ui:FieldTemplate': CollapseTemplate,
    'ui:layout': [1, 2],
    'ui:options': {
      label: false, // 不显示 label
    },
    direction: {
      'ui:field': DirectionField,
      'ui:options': {
        useNewPick: true,
        options: [
          {
            const: DirectionType.NormalToSource,
            title: i18n.t('Normal to Source'),
          },
          {
            const: DirectionType.UserDefined,
            title: i18n.t('User Defined'),
          },
        ],
      },
    },
    distance: {
      'ui:field': 'inputField',
      'ui:type': 'number',
    },
    count: {
      'ui:field': 'inputField',
      'ui:type': 'number',
    },
    size: {
      'ui:field': 'inputField',
      'ui:type': 'number',
    },
    NumberOrSize: {
      'ui:widget': 'radio',
    },
  },
  AddTo: {
    'ui:FieldTemplate': CollapseTemplate,
    'ui:layout': [1, 2],
    'ui:options': {
      label: false, // 不显示 label
    },
    property: {
      'ui:field': 'partMaterialField',
    },
    part: {
      'ui:field': 'partMaterialField',
    },
  },
};
